//
//  StatusForwardCell.swift
//  我的微博
//
//  Created by ZhangChao on 15/9/10.
//  Copyright © 2015年 ZhangChao. All rights reserved.
//

import UIKit

class StatusForwardCell: StatusCell {
    
    override var statusViewModel: StatusViewModel?{
        didSet{
            
            forwardLabel.text = statusViewModel?.forwardText
        }
    }
    
    /// MARK: - 懒加载控件
    
    private lazy var backgroundButton : UIButton = {
       
        let btn = UIButton()
        
        btn.backgroundColor = UIColor(white: 0.9, alpha: 1)
        
        return btn
    }()
    
    private lazy var forwardLabel : UILabel = UILabel(title: "转发微博", color: UIColor.darkGrayColor(), fontSize: 14,layoutWidth: UIScreen.mainScreen().bounds.width - 2 * statusCellMargin)
    
    // 设置UI
    override func setupUI() {
        
        super.setupUI()
        
        // 添加控件
        contentView.insertSubview(backgroundButton, belowSubview: pictureView)
        contentView.addSubview(forwardLabel)
        
        // 自动布局
        // 背景按钮
        backgroundButton.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: contentLabel, size: nil, offset: CGPoint(x: -statusCellMargin, y: statusCellMargin))
        backgroundButton.ff_AlignVertical(type: ff_AlignType.TopRight, referView: bottomView, size: nil)
        // 转发文字
        forwardLabel.ff_AlignInner(type: ff_AlignType.TopLeft, referView: backgroundButton, size: nil, offset: CGPoint(x: statusCellMargin, y: statusCellMargin))
        // 图片
        let cons = pictureView.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: forwardLabel, size: CGSize(width: statusPictureMaxWidth, height: statusPictureMaxWidth), offset: CGPoint(x: 0, y: statusCellMargin))
        // 记录约束
        pictureViewWidthCons = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Width)
        pictureViewHeightCons = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Height)
        pictureViewTopCons = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Top)
    }
}
